package com.ensah.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.boudaa.dao.exceptions.EntityNotFoundException;
import com.ensah.dao.AttestationDao;
import com.ensah.metier.bo.Attestation;
import com.ensah.service.AttestationService;

public class AttestationServiceImpl implements AttestationService{

	private AttestationDao attDao;
	
	public Attestation getAttestationById(Long id) throws EntityNotFoundException {
		
		
		return attDao.findById(id);
	}

	
	


	public Attestation saveAttestation(Attestation at) {
		
		
		return attDao.create(at);
	}


	
	public void deleteAttestation(Long id) {

		
		attDao.delete(id);
	}


	
	public void updateAttestation(Attestation at) {

		attDao.update(at);
	}


	public AttestationDao getAttDao() {
		return attDao;
	}


	public void setAttDao(AttestationDao attDao) {
		this.attDao = attDao;
	}



	public List<Attestation> getListeAtt() {

		List<Attestation> list=new ArrayList<Attestation>();
		
		for(Attestation it:attDao.getAll()){
			
			if(it.isEtat()==false)
				
				list.add(it);
			
		}
		
		return list;
	}



	public List<Attestation> getListeAttByCne(String cne) {
		
List<Attestation> list=new ArrayList<Attestation>();
		
		for(Attestation it:attDao.getAll()){
			
			if(it.getEtudiant().getCne()==cne)
				
				list.add(it);
			
		}
		
		return list;
	}

}
